package com.projects.android.views;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
import com.projects.android.R;

public class RestaurantFoods extends TabActivity {
	// Use an existing ListAdapter that will map an array
	// of strings to TextViews
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		initTabs();
	}
	
	private void initTabs(){
		Resources res = getResources(); // Resource object to get Drawables
		TabHost tabHost = getTabHost(); // The activity			
		tabHost.setup(); 
		tabHost.clearAllTabs();
		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, Menu.class);
		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost
				.newTabSpec("menu")
				.setIndicator("Menu",
						res.getDrawable(R.drawable.ic_tab_artists))
				.setContent(intent);
		tabHost.addTab(spec);
		
		// Do the same for the other tabs
		intent = new Intent().setClass(this, Cart.class);
		spec = tabHost
				.newTabSpec("cart")
				.setIndicator("Cart",
						res.getDrawable(R.drawable.ic_tab_songs))
				.setContent(intent);
		tabHost.addTab(spec);
		
		// Set default selected tab
		tabHost.setCurrentTab(0);
	}
}
